#include <string.h>
#include <assert.h>

#include <vector>
#include <string>

#include "mpreal.h"

// 定义一个函数指针类型，用于传递一个函数指针,函数用于计算在某一点的误差,或者计算函数在某一点的导数
using Error_FP = mpfr::mpreal (*) (const std::vector<mpfr::mpreal> &, mpfr::mpreal, int);

// 计算多项式在x处的值
extern mpfr::mpreal evaluatePolynomial( const std::vector<mpfr::mpreal> &coeffs, 
     mpfr::mpreal x, int degree);
 
// 计算多项式在x处的导数值
extern mpfr::mpreal polynomial_derivative( const std::vector<mpfr::mpreal> &coeffs, 
     mpfr::mpreal x, int degree);

extern void chebyshev_nodes(std::vector<mpfr::mpreal> &nodes,
     mpfr::mpreal a, mpfr::mpreal b, int n,const char *MPREAL_FORMAT );

extern void init_nodes_v2(std::vector<mpfr::mpreal> &nodes,
     mpfr::mpreal a, mpfr::mpreal b, int n );

extern mpfr::mpreal search_extre_point(
     const std::vector<mpfr::mpreal> &coeffs,
     Error_FP fp,
     int degree,  mpfr::mpreal begin, mpfr::mpreal end);

extern std::vector<mpfr::mpreal> calc_error_extremum(
     const std::vector<mpfr::mpreal> &coeffs,
     Error_FP fp,
     mpfr::mpreal a, mpfr::mpreal b, int degree);

extern void print_coeffs( const std::vector<mpfr::mpreal> &coeffs,const char *MPREAL_FORMAT);
extern void print_nodes( const std::vector<mpfr::mpreal> &coeffs,const char *MPREAL_FORMAT);
extern std::string get_ordinal_number( int i);
extern std::vector<double> get_glibc_coeffs();

extern std::vector<mpfr::mpreal> select_nodes(
     const std::vector<mpfr::mpreal> &coeffs,
     Error_FP fp1,
     Error_FP fp2,
     mpfr::mpreal a,mpfr::mpreal b, int degree, int n,
     const char *MPREAL_FORMAT);



